package com.wanmait.employment.manageController;

import com.wanmait.employment.entity.ExpectedSalary;
import com.wanmait.employment.service.ExpectedSalaryService;
import com.wanmait.employment.util.AjaxResult;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * Create By pc on 2023/5/25.
 * 薪资期望表
 */
@RestController
@RequestMapping("/manage/ExpectedSalary")
public class ExpectedSalaryController {
    @Resource
    private ExpectedSalaryService experctedSalaryService;
    @GetMapping("list")
    public AjaxResult list(String title) {
        List<ExpectedSalary> expectedSalaryList = experctedSalaryService.selectList(title);
        return AjaxResult.success(expectedSalaryList);
    }

    @PostMapping("update")
    public AjaxResult update(@RequestBody ExpectedSalary expectedSalary) {
        if (expectedSalary.getId() != null) {
            experctedSalaryService.update(expectedSalary);
            return AjaxResult.success("成功");
        }
        experctedSalaryService.insert(expectedSalary);
        return AjaxResult.success("成功");
    }
    @PostMapping("insert")
        public AjaxResult insert(@RequestBody ExpectedSalary expectedSalary){
        experctedSalaryService.insert(expectedSalary);
        return AjaxResult.success("添加成功");
    }

    @GetMapping("delete")
    public  AjaxResult delete(Integer id){
      experctedSalaryService.delete(id);
      return AjaxResult.success("删除成功");
    }
}
